package com.oig.sys.msg.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.oig.common.validator.EnumValue;
import com.oig.common.validator.GroupAdd;
import com.oig.common.validator.GroupChange;
import com.oig.common.validator.GroupComplete;
import com.oig.common.validator.GroupEdit;
import com.oig.sys.msg.constants.MsgEnums;
import io.swagger.v3.oas.annotations.media.Schema;

import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;

@Schema
@Data
public class TaskDto {

	@Schema(description = "任务id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotNull(message = "参数错误,任务id不能为空", groups={GroupEdit.class, GroupComplete.class, GroupChange.class})
	private Integer id;

	@Schema(description = "任务标题", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotEmpty(message = "参数错误,任务标题不能为空", groups={GroupAdd.class, GroupEdit.class})
	@Length(max = 128, message = "任务标题长度不能超过128个字符", groups ={GroupAdd.class, GroupEdit.class} )
	private String taskTitle;
	@Schema(description = "任务内容", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotEmpty(message = "参数错误,任务内容不能为空", groups={GroupAdd.class, GroupEdit.class})
	private String taskContent;
	@Schema(description = "任务优先级")
	@EnumValue(message = "列值类型值不对", enumClass= MsgEnums.TaskPriority.class, enumValidMethod ="validCode")
	private String taskPriority;
	@Schema(description = "任务重要等级")
	@EnumValue(message = "列值类型值不对", enumClass= MsgEnums.TaskLevel.class, enumValidMethod ="validCode")
	private String taskLevel;
	@Schema(description = "关联单据类型")
	private String relationType;
	@Schema(description = "关联单号")
	private String relationId;
	@Schema(description = "处理人id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotNull(message = "参数错误,处理人id不能为空", groups={GroupAdd.class,GroupEdit.class, GroupChange.class})
	private Integer dealId;
	@Schema(description = "处理人名", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotEmpty(message = "参数错误,处理人名不能为空", groups={GroupAdd.class, GroupEdit.class, GroupChange.class})
	private String dealName;

	@Schema(description = "预估工时")
	private BigDecimal taskHours;
	@Schema(description = "计划开始日期")
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date planStartTime;
	@Schema(description = "计划完成日期")
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date planEndTime;
	@Schema(description = "实际开始时间")
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date startTime;
	@Schema(description = "实际完成时间")
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date finishTime;
	@Schema(description = "实际工时")
	private BigDecimal usedHours;
	@Schema(description = "任务跟踪人id")
	private Integer watchId;
	@Schema(description = "任务跟踪人名")
	private String watchName;

	@Schema(description = "所属租户id")
	private Integer tenantId;
	@Schema(description = "所属租户名称")
	private String tenantName;

	@Schema(description = "消息发布人id")
	private Integer createUserId;
	@Schema(description = "消息发布人")
	private String createUserName;
	@Schema(description = "消息发布人时间")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date createTime;

	@Schema(description = "消息修改人id")
	private Integer lastUpdateId;
	@Schema(description = "消息修改人")
	private String lastUpdateName;
	@Schema(description = "消息修改人时间")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date lastUpdateTime;

	@Schema(description = "备注,指派、完成、拒绝、延期操作备注内容填这里")
	private String logRemark;
    @Schema(description = "状态")
	private String status;
}
